From 28306bccb73ee14b5732f182d3e86c5d0c4d92c5 Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Thu, 8 Dec 2016 17:17:04 -0800 Subject: [PATCH] fix out of bound access to mode_strings mode == ARRAY_SIZE(mode_strings) causes an out of bound access to the mode_strings array. Coverity-ID: 1381859 Signed-off-by: Stefano Stabellini Reviewed-by: Julien Grall --- xen/arch/arm/traps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index eb85d92c6d..35d8e8b09a 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -643,7 +643,7 @@ static const char *mode_string(uint32_t cpsr) }; mode = cpsr & PSR_MODE_MASK; - if ( mode > ARRAY_SIZE(mode_strings) ) + if ( mode >= ARRAY_SIZE(mode_strings) ) return "Unknown"; return mode_strings[mode] ? : "Unknown"; } -- 2.30.2